#include <iostream>
using namespace std;
 
template <typename Child>
struct Base
{
    void interface()
    {
        static_cast<Child*>(this)->implementation();
    }
};
 
template<typename T, 
        template <typename> typename Base>
struct Derived : Base<Derived<T, Base>>
{
    void implementation(T t=0)
    {
        t = 0;
        cerr << "Derived implementation----" << t;
    }
};



int main()
{
    Derived<int, Base> d; // Base class as a template parameter is must  
    d.interface();  // Prints "Derived implementation"

    return 0;
}

#include <iostream>
using namespace std;
 
template <typename Child>
struct Base
{
    void interface()
    {
        static_cast<Child*>(this)->implementation();
    }
};
 
template<typename T, 
        template <typename> class Base>
struct Derived : Base<Derived<T, Base> >
{
    void implementation(T t=0)
    {
        t = 0;
        cerr << "Derived implementation----" << t;
    }
};



int main()
{
    Derived<int, Base> d; // Base class as a template parameter is must  
    d.interface();  // Prints "Derived implementation"

    return 0;
}
